package com.itheima.arraylist;

import java.util.ArrayList;

/*
ArrayList
增删改查 遍历


 */
public class Demo01 {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("蔡徐坤1");
        list.add("蔡徐坤2");
        list.add("蔡徐坤3");
        list.add("蔡徐坤4");
        list.add("蔡徐坤4");

        list.add(0, "蔡徐坤0");
        System.out.println(list);
        list.remove(5);
        System.out.println(list);
        list.set(3, "蔡徐坤333333333333");
        System.out.println(list);
        System.out.println(list.get(4));
        for (String s : list) {
            System.out.println(s);
        }
        list.forEach(s -> System.out.println(s));
       /* System.out.println("-------------------");
        System.out.println(list);
        for (String s : list) {

            if(s.equals("蔡徐坤4")){
                list.remove(s);
            }
        }*/
        System.out.println("-------------------");
        System.out.println(list);

        list.forEach(x -> {
                  list.add("hahaha");
                }
        );
    }
}
